*&---------------------------------------------------------------------*
*& 包含               ZFIU020_CLS
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
*       CLASS lcl_events DEFINITION
*----------------------------------------------------------------------*
* SALV Event Handler Definition                                        *
*----------------------------------------------------------------------*
CLASS GCL_EVENTS_HANDLER DEFINITION.
  PUBLIC SECTION.
    METHODS:
      ON_LINK_CLICK FOR EVENT LINK_CLICK  "Hotspot Handler
        OF CL_SALV_EVENTS_TABLE
        IMPORTING ROW COLUMN,

      ON_USER_COMMAND FOR EVENT ADDED_FUNCTION OF CL_SALV_EVENTS
        IMPORTING E_SALV_FUNCTION.
ENDCLASS.                    "lcl_events DEFINITION
*
*----------------------------------------------------------------------*
*       CLASS lcl_events IMPLEMENTATION
*----------------------------------------------------------------------*
*  SAL Event Handler Methods                                           *
*----------------------------------------------------------------------*
CLASS GCL_EVENTS_HANDLER IMPLEMENTATION.
  METHOD ON_LINK_CLICK.
    DATA:
      LV_TCODE      TYPE SY-TCODE,
      LS_PARAMETER  TYPE /PTGWFI/PIDVAL,
      LT_PARAMETERS TYPE TABLE OF /PTGWFI/PIDVAL,
      LV_MSG1(80)   TYPE C,
      LV_MSG2(80)   TYPE C.

    READ TABLE GT_RESULT INTO DATA(LS_RESULT) INDEX ROW.
    IF SY-SUBRC = 0.
      CASE COLUMN.
        WHEN 'JSDDH'.
          SET PARAMETER ID 'ZJSDDH' FIELD LS_RESULT-JSDDH.
          CALL TRANSACTION 'ZFIU019_01' AND SKIP FIRST SCREEN.

        WHEN 'DOCID'.

          IF LS_RESULT-DOCID IS NOT INITIAL.
            CALL FUNCTION '/OPT/VIM_DISPLAY_DOCUMENT'
              EXPORTING
                DOCID                 = LS_RESULT-DOCID
                POPUP                 = 'X'
              EXCEPTIONS
                INVALID_DOCUMENT      = 1
                SYSTEM_FAILURE        = 2 MESSAGE LV_MSG2
                COMMUNICATION_FAILURE = 3
                OTHERS                = 4.
            IF SY-SUBRC EQ 1.
              MESSAGE I075(/OPT/VIM_M_CLASS).
            ELSEIF SY-SUBRC EQ 2 OR
                   SY-SUBRC EQ 3.
              MESSAGE LV_MSG2 TYPE 'S' DISPLAY LIKE 'E'.

            ELSEIF SY-SUBRC NE 0.
              MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
            ENDIF.
          ENDIF.

        WHEN 'BELNR'.

          CHECK NOT LS_RESULT-BELNR IS INITIAL.
          SET PARAMETER ID 'BLN' FIELD LS_RESULT-BELNR.
          SET PARAMETER ID 'GJR' FIELD LS_RESULT-GJAHR.
          SET PARAMETER ID 'BUK' FIELD LS_RESULT-BUKRS.
          CALL FUNCTION 'AUTHORITY_CHECK_TCODE'             "2334943
            EXPORTING
              TCODE  = 'FB03'
            EXCEPTIONS
              OK     = 1
              NOT_OK = 2
              OTHERS = 3.

          IF SY-SUBRC <> 1.
            MESSAGE E172(00) WITH 'FB03'.
          ELSE.
            CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
          ENDIF.

        WHEN 'EBELN'.

          IF LS_RESULT-EBELN IS NOT INITIAL.

            LV_TCODE = 'ME23N'.
            MOVE 'BES'      TO LS_PARAMETER-PID.
            MOVE LS_RESULT-EBELN   TO LS_PARAMETER-VALUE.
            APPEND LS_PARAMETER TO LT_PARAMETERS.

            CALL FUNCTION '/PTGWFI/CP_CALLTRANSACTION'
              EXPORTING
                TRAN_CODE             = LV_TCODE
              TABLES
                PID_VAL               = LT_PARAMETERS
              EXCEPTIONS
*               OTHERS                = 1.
* Start of CHG VIMI-18450
                SYSTEM_FAILURE        = 1 MESSAGE LV_MSG1
                COMMUNICATION_FAILURE = 2
                OTHERS                = 3.
            IF SY-SUBRC EQ 1 .
              MESSAGE LV_MSG1 TYPE 'S' DISPLAY LIKE 'E'.

            ELSEIF SY-SUBRC EQ 2 .
              MESSAGE LV_MSG2 TYPE 'S' DISPLAY LIKE 'E'.

            ELSEIF SY-SUBRC = 3.
              MESSAGE I076(/OPT/VIM_M_CLASS).
            ENDIF.
          ENDIF.

        WHEN 'MBLNR' OR 'MJAHR' OR 'ZEILE'.
          IF LS_RESULT-MBLNR IS NOT INITIAL AND LS_RESULT-MJAHR IS NOT INITIAL.
            SET PARAMETER ID 'MBN' FIELD LS_RESULT-MBLNR.
            SET PARAMETER ID 'MJA' FIELD LS_RESULT-MJAHR.
            CALL FUNCTION 'MIGO_DIALOG'
              EXPORTING
                I_ACTION            = 'A04'
                I_REFDOC            = 'R02'
                I_NOTREE            = 'X'
                I_SKIP_FIRST_SCREEN = 'X'
                I_DEADEND           = 'X'
                I_MBLNR             = LS_RESULT-MBLNR
                I_MJAHR             = LS_RESULT-MJAHR.
          ENDIF.

        WHEN OTHERS.
      ENDCASE.
    ENDIF.

  ENDMETHOD.

  METHOD ON_USER_COMMAND.
    CASE E_SALV_FUNCTION.
      WHEN '&ZREFRESH'.
        PERFORM FRM_GET_DATA.

        DATA:
          LR_COLUMNS    TYPE REF TO CL_SALV_COLUMNS_TABLE.

        LR_COLUMNS = GR_TABLE->GET_COLUMNS( ).
        LR_COLUMNS->SET_OPTIMIZE( 'X' ).
        GR_TABLE->REFRESH( ).
      WHEN OTHERS.
    ENDCASE.
  ENDMETHOD.
  "on_link_click
ENDCLASS.                    "lcl_events IMPLEMENTATION

DATA: GR_EVENTS_HANDLER TYPE REF TO GCL_EVENTS_HANDLER.
